<template>
  <div class="app-container">
    <div style="margin: 20px;"></div>
    <el-form label="left" label-position="left" label-width="80px">
      <el-form-item label="学科：" style="width: 300px;">
        <el-select v-model="form.sid" placeholder="选择学科">
          <el-option v-for="item in subjectFilter" :key="item.cid" :value="item.sid"
                     :label="item.subName+' ( '+item.uid+' )'"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="知识点" style="width: 300px;">
        <el-input v-model="form.point" placeholder="请输入知识点"></el-input>
      </el-form-item>
      <el-form-item style="width: 200px;margin-left: 50px">
        <el-button type="primary" @click="onSubmit">添加</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import {addKnowledge, getCourse} from '../../api/data'

export default {
  name: "add-knowledge",
  data() {
    return {
      subjectFilter: [],
      form: {
        sid: null,//课程号
        point: '',//知识点名称
      }
    };
  },
  methods: {
    onSubmit() {
      let data = {sid: this.form.sid, point: this.form.point};
      console.log(data);
      addKnowledge(data);
    }
  },
  mounted() {
    getCourse().then(res => {
      this.subjectFilter = res.data;
    })
  },
}
</script>

<style scoped>
.app-container {
  margin-left: 500px;
}
</style>
